const { app, BrowserWindow} = require('electron')
const { session } = require('electron')

app.commandLine.appendSwitch('disable-features','BlockInsecurePrivateNetworkRequests')
app.commandLine.appendSwitch('--no-proxy-server','true')
app.commandLine.appendSwitch('--auth-server-whitelist','*example.com, *foobar.com, *baz')
app.commandLine.appendSwitch('--auth-negotiate-delegate-whitelist','*')
app.commandLine.appendSwitch('disable-web-security');
app.commandLine.appendSwitch('--ignore-certificate-errors', 'true')

let win
function createWindow () {
     win = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            nodeIntegration:true,
            contextIsolation:false,
            webSecurity: false, // 禁用同源策略
        },
        icon:'/home/liuyin/文档/workspace/electron-demo/logo.icns'
    })

    // win.loadURL('http://localhost:8080/')
    win.loadFile('index.html')
}

app.whenReady().then(() => {
    createWindow()

    app.on('activate', () => {
        if (BrowserWindow.getAllWindows().length === 0) {
            createWindow()
        }
    })

})
